#include "screens.h"
#include <QDebug>

screens::screens(QWidget *parent, QUrl f) : Phonon::VideoWidget(0) {
    this->parent = parent;
    fileLocation = f;   
    // File which will be shown
    mediaObject = new Phonon::MediaObject(this);
    mediaObject->setCurrentSource(Phonon::MediaSource(fileLocation));
    Phonon::createPath(mediaObject, this);
    connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(restartVideo()));

}

screens::~screens(){
}

void screens::restartVideo(){
    mediaObject->seek(0);
}

void screens::playMedia(){
    mediaObject->play();
}

void screens::pauseMedia(){
    mediaObject->pause();
}

void screens::stopMedia(){
    mediaObject->stop();
}

void screens::keyPressEvent(QKeyEvent * event){
    parent->activateWindow();
}

void screens::syncMedia(){
    mediaObject->seek(0);
}

void screens::setMediaObject(QUrl f){
    mediaObject->setCurrentSource(Phonon::MediaSource(f));
    mediaObject->seek(0);
}
